﻿using Medianamik.Core;
using Medianamik.Core.Configuration;
using Medianamik.Core.Urls;
using NUnit.Framework;

namespace Medianamik.Tests.Integration.Medianamik.Core.Urls
{
    [TestFixture]
    public class UrlDictionaryTest
    {
        private static readonly MedianamikConfigSection MedianamikConfig = new MedianamikConfigSection();

        [SetUp]
        public void Init()
        {
            //Configurations par défault
            MedianamikConfig.DefaultPageExtension = ".html";
            MedianamikConfig.SendUrlDictionaryReport = false;
        }

        [Test]
        public void UrlDictionnay_should_always_contains_the_same_entries()
        {
            var urlDict = new UrlFastDictionary();
            urlDict.Initialize(MedianamikConfig);

            for (var i = 0; i < 20; i++)
            {
                var tmpDict = new UrlFastDictionary();
                tmpDict.Initialize(MedianamikConfig);

                Assert.That(tmpDict.Count, Is.EqualTo(urlDict.Count));
                tmpDict.GetAllEntries().ForEach(url => Assert.That(urlDict.Contains(url)));
            }
        }
    }
}